package pl.com.qapps.datastore;

import com.google.appengine.api.datastore.AsyncDatastoreService;
import com.google.appengine.api.datastore.DatastoreFailureException;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceConfig;

/**
 * 
 * @author Jakub Dykowski
 * 
 */
public interface Datastore {

	/**
	 * Creates rather lightweight asynchronous view on stored data. With own
	 * transaction provider and eventual own independent cache. If given
	 * configuration is null, the default is taken.
	 * 
	 * @param cfg
	 *            , can be null
	 * @return new DatastoreService instance
	 */
	DatastoreService getDatastoreService(DatastoreServiceConfig cfg);

	/**
	 * Creates rather lightweight asynchronous view on stored data. With own
	 * transaction provider and eventual own independent cache. If given
	 * configuration is null, the default configuration is taken.
	 * 
	 * @param cfg
	 *            , can be null
	 * @return new DatastoreService instance
	 */
	AsyncDatastoreService getAsyncDatastoreService(DatastoreServiceConfig cfg);

	/**
	 * 
	 * @throws DatastoreFailureException
	 *             if some internal, implementation dependent exception occurs
	 *             while closing eny ressources.
	 * @throws IllegalStateException
	 *             if cannot be closed due to internal, implementation dependent
	 *             illegal state.
	 */
	void close() throws DatastoreFailureException;
}
